package com.ltmonitor.web.controller.video;

import com.ltmonitor.service.IPlatformStateService;
import com.ltmonitor.service.IVehicleOsdService;
import com.ltmonitor.service.IVideoServerConfigService;
import com.ltmonitor.video.entity.VehicleOsd;
import com.ltmonitor.video.entity.VideoServerConfig;
import com.ltmonitor.web.controller.GenericAction;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * 车辆字幕叠加配置
 * 
 * @author DELL
 * 
 */
@Controller
@RequestMapping("/vehicleOsd")
public class VehicleOsdAction extends GenericAction {
	@Autowired
	protected IVehicleOsdService vehicleOsdService;

	protected String EditViewName = "/vehicleOsd/editvehicleOsd";
	
	@RequestMapping("/view.action")
	public String view(
			Model m) {
		try {
			VehicleOsd vc = this.vehicleOsdService.getVehicleOsd();
			if(vc == null)
				vc = new VehicleOsd();
			m.addAttribute("entity", vc);

		} catch (Exception ex) {
			log.error(ex.getMessage(), ex);
			m.addAttribute("message", "发生错误:" + ex.getMessage());
		}
		return "/video/editVehicleOsd";
	}
	
	/**
	 * 新增后的保存操作
	 * 
	 * @return
	 */
	@RequestMapping("/save")
	public String save(VehicleOsd d, Model m) throws Exception {

		try {
			//d.setMainDriver(mainDriver);
			//一个车只能有一个主驾驶，需要将同一车的其他主驾驶设置为false
			this.vehicleOsdService.saveOrUpdate(d);

			m.addAttribute("message", "保存成功");
		} catch (Exception ex) {
			log.error(ex.getMessage(), ex);
			m.addAttribute("message", ex.getMessage());
		}
		m.addAttribute("entity", d);

		return "/video/editVehicleOsd";
	}
	

}
